package com.tabjin.rfidsocket.authority.shiro;

import org.springframework.stereotype.Component;

/**
 * @author Tabjin
 * create at 2021/2/27 09:52
 * @program emos-wx-api
 * @description Filter类和AOP切面类之间传递数据的媒介类，传递Token
 */
@Component
public class ThreadLocalToken {
    private ThreadLocal<String> local = new ThreadLocal<>();

    /**
     * 将 Token 令牌保存到 ThreadLocal 中
     *
     * @param token
     */
    public void setToken(String token) {
        local.set(token);
    }

    /**
     * 从 ThreadLocal 中获取 Token
     *
     * @return
     */
    public String getToken() {
        return local.get();
    }

    public void clear() {
        local.remove();
    }
}
